<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">System.Console.Haskeline.Term</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-2"></span><span>
</span><span id="line-3"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="System.Console.Haskeline.Monads.html"><span class="hs-identifier">System.Console.Haskeline.Monads</span></a></span><span>
</span><span id="line-4"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="System.Console.Haskeline.LineState.html"><span class="hs-identifier">System.Console.Haskeline.LineState</span></a></span><span>
</span><span id="line-5"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="System.Console.Haskeline.Key.html"><span class="hs-identifier">System.Console.Haskeline.Key</span></a></span><span>
</span><span id="line-6"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="System.Console.Haskeline.Prefs.html"><span class="hs-identifier">System.Console.Haskeline.Prefs</span></a></span><span class="hs-special">(</span><span class="annot"><a href="System.Console.Haskeline.Prefs.html#Prefs"><span class="hs-identifier">Prefs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-7"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="System.Console.Haskeline.Completion.html"><span class="hs-identifier">System.Console.Haskeline.Completion</span></a></span><span class="hs-special">(</span><span class="annot"><a href="System.Console.Haskeline.Completion.html#Completion"><span class="hs-identifier">Completion</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-8"></span><span>
</span><span id="line-9"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Control.Concurrent.html#"><span class="hs-identifier">Control.Concurrent</span></a></span><span>
</span><span id="line-10"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../stm/src/Control.Concurrent.STM.html#"><span class="hs-identifier">Control.Concurrent.STM</span></a></span><span>
</span><span id="line-11"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Control.Exception.html#"><span class="hs-identifier">Control.Exception</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Exception.Type.html#Exception"><span class="hs-identifier">Exception</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Exception.Type.html#SomeException"><span class="hs-identifier">SomeException</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-12"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../exceptions/src/Control.Monad.Catch.html#"><span class="hs-identifier">Control.Monad.Catch</span></a></span><span>
</span><span id="line-13"></span><span>    </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="../../exceptions/src/Control.Monad.Catch.html#MonadMask"><span class="hs-identifier">MonadMask</span></a></span><span>
</span><span id="line-14"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../exceptions/src/Control.Monad.Catch.html#bracket"><span class="hs-identifier">bracket</span></a></span><span>
</span><span id="line-15"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../exceptions/src/Control.Monad.Catch.html#handle"><span class="hs-identifier">handle</span></a></span><span>
</span><span id="line-16"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../exceptions/src/Control.Monad.Catch.html#throwM"><span class="hs-identifier">throwM</span></a></span><span>
</span><span id="line-17"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../exceptions/src/Control.Monad.Catch.html#finally"><span class="hs-identifier">finally</span></a></span><span>
</span><span id="line-18"></span><span>    </span><span class="hs-special">)</span><span>
</span><span id="line-19"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.Word.html#"><span class="hs-identifier">Data.Word</span></a></span><span>
</span><span id="line-20"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Control.Exception.html#"><span class="hs-identifier">Control.Exception</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Exception.Type.html#fromException"><span class="hs-identifier">fromException</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Exception.html#AsyncException"><span class="hs-identifier">AsyncException</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-21"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.Typeable.html#"><span class="hs-identifier">Data.Typeable</span></a></span><span>
</span><span id="line-22"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/System.IO.html#"><span class="hs-identifier">System.IO</span></a></span><span>
</span><span id="line-23"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Control.Monad.html#"><span class="hs-identifier">Control.Monad</span></a></span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Base.html#liftM"><span class="hs-identifier">liftM</span></a></span><span class="hs-special">,</span><span class="annot"><a href="../../base/src/GHC.Base.html#when"><span class="hs-identifier">when</span></a></span><span class="hs-special">,</span><span class="annot"><a href="../../base/src/Control.Monad.html#guard"><span class="hs-identifier">guard</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-24"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/System.IO.Error.html#"><span class="hs-identifier">System.IO.Error</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/System.IO.Error.html#isEOFError"><span class="hs-identifier">isEOFError</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-25"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../bytestring/src/Data.ByteString.html#"><span class="hs-identifier">Data.ByteString</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../bytestring/src/Data.ByteString.Internal.html#ByteString"><span class="hs-identifier">ByteString</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-26"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="../../bytestring/src/Data.ByteString.Char8.html#"><span class="hs-identifier">Data.ByteString.Char8</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">BC</span></span><span>
</span><span id="line-27"></span><span>
</span><span id="line-28"></span><span class="hs-keyword">class</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="System.Console.Haskeline.Monads.html#MonadReader"><span class="hs-identifier hs-type">MonadReader</span></a></span><span> </span><span class="annot"><a href="System.Console.Haskeline.Term.html#Layout"><span class="hs-identifier hs-type">Layout</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679095048"><span class="hs-identifier hs-type">m</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/Control.Monad.IO.Class.html#MonadIO"><span class="hs-identifier hs-type">MonadIO</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679095048"><span class="hs-identifier hs-type">m</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../exceptions/src/Control.Monad.Catch.html#MonadMask"><span class="hs-identifier hs-type">MonadMask</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679095048"><span class="hs-identifier hs-type">m</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span id="Term"><span class="annot"><a href="System.Console.Haskeline.Term.html#Term"><span class="hs-identifier hs-var">Term</span></a></span></span><span> </span><span id="local-6989586621679095048"><span class="annot"><a href="#local-6989586621679095048"><span class="hs-identifier hs-type">m</span></a></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-29"></span><span>    </span><span id="reposition"><span class="annot"><a href="System.Console.Haskeline.Term.html#reposition"><span class="hs-identifier hs-type">reposition</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="System.Console.Haskeline.Term.html#Layout"><span class="hs-identifier hs-type">Layout</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="System.Console.Haskeline.LineState.html#LineChars"><span class="hs-identifier hs-type">LineChars</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679095048"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-30"></span><span>    </span><span id="moveToNextLine"><span class="annot"><a href="System.Console.Haskeline.Term.html#moveToNextLine"><span class="hs-identifier hs-type">moveToNextLine</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="System.Console.Haskeline.LineState.html#LineChars"><span class="hs-identifier hs-type">LineChars</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679095048"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-31"></span><span>    </span><span id="printLines"><span class="annot"><a href="System.Console.Haskeline.Term.html#printLines"><span class="hs-identifier hs-type">printLines</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679095048"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-32"></span><span>    </span><span id="drawLineDiff"><span class="annot"><a href="System.Console.Haskeline.Term.html#drawLineDiff"><span class="hs-identifier hs-type">drawLineDiff</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="System.Console.Haskeline.LineState.html#LineChars"><span class="hs-identifier hs-type">LineChars</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="System.Console.Haskeline.LineState.html#LineChars"><span class="hs-identifier hs-type">LineChars</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679095048"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-33"></span><span>    </span><span id="clearLayout"><span class="annot"><a href="System.Console.Haskeline.Term.html#clearLayout"><span class="hs-identifier hs-type">clearLayout</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="#local-6989586621679095048"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-34"></span><span>    </span><span id="ringBell"><span class="annot"><a href="System.Console.Haskeline.Term.html#ringBell"><span class="hs-identifier hs-type">ringBell</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679095048"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-35"></span><span>
</span><span id="line-36"></span><span id="local-6989586621679095045"><span class="annot"><a href="System.Console.Haskeline.Term.html#drawLine"><span class="hs-identifier hs-type">drawLine</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="System.Console.Haskeline.Term.html#clearLine"><span class="hs-identifier hs-type">clearLine</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="System.Console.Haskeline.Term.html#Term"><span class="hs-identifier hs-type">Term</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679095045"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="System.Console.Haskeline.LineState.html#LineChars"><span class="hs-identifier hs-type">LineChars</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679095045"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span></span><span>
</span><span id="line-37"></span><span id="drawLine"><span class="annot"><span class="annottext">drawLine :: forall (m :: * -&gt; *). Term m =&gt; LineChars -&gt; m ()
</span><a href="System.Console.Haskeline.Term.html#drawLine"><span class="hs-identifier hs-var hs-var">drawLine</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LineChars -&gt; LineChars -&gt; m ()
forall (m :: * -&gt; *). Term m =&gt; LineChars -&gt; LineChars -&gt; m ()
</span><a href="System.Console.Haskeline.Term.html#drawLineDiff"><span class="hs-identifier hs-var">drawLineDiff</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">,</span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-38"></span><span>
</span><span id="line-39"></span><span id="clearLine"><span class="annot"><span class="annottext">clearLine :: forall (m :: * -&gt; *). Term m =&gt; LineChars -&gt; m ()
</span><a href="System.Console.Haskeline.Term.html#clearLine"><span class="hs-identifier hs-var hs-var">clearLine</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(LineChars -&gt; LineChars -&gt; m ()) -&gt; LineChars -&gt; LineChars -&gt; m ()
forall a b c. (a -&gt; b -&gt; c) -&gt; b -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#flip"><span class="hs-identifier hs-var">flip</span></a></span><span> </span><span class="annot"><span class="annottext">LineChars -&gt; LineChars -&gt; m ()
forall (m :: * -&gt; *). Term m =&gt; LineChars -&gt; LineChars -&gt; m ()
</span><a href="System.Console.Haskeline.Term.html#drawLineDiff"><span class="hs-identifier hs-var">drawLineDiff</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">,</span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-40"></span><span>
</span><span id="line-41"></span><span class="hs-keyword">data</span><span> </span><span id="RunTerm"><span class="annot"><a href="System.Console.Haskeline.Term.html#RunTerm"><span class="hs-identifier hs-var">RunTerm</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="RunTerm"><span class="annot"><a href="System.Console.Haskeline.Term.html#RunTerm"><span class="hs-identifier hs-var">RunTerm</span></a></span></span><span> </span><span class="hs-special">{</span><span>
</span><span id="line-42"></span><span>            </span><span class="hs-comment">-- | Write unicode characters to stdout.</span><span>
</span><span id="line-43"></span><span>            </span><span id="putStrOut"><span class="annot"><span class="annottext">RunTerm -&gt; String -&gt; IO ()
</span><a href="System.Console.Haskeline.Term.html#putStrOut"><span class="hs-identifier hs-var hs-var">putStrOut</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span class="hs-special">,</span><span>
</span><span id="line-44"></span><span>            </span><span id="termOps"><span class="annot"><span class="annottext">RunTerm -&gt; Either TermOps FileOps
</span><a href="System.Console.Haskeline.Term.html#termOps"><span class="hs-identifier hs-var hs-var">termOps</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/Data.Either.html#Either"><span class="hs-identifier hs-type">Either</span></a></span><span> </span><span class="annot"><a href="System.Console.Haskeline.Term.html#TermOps"><span class="hs-identifier hs-type">TermOps</span></a></span><span> </span><span class="annot"><a href="System.Console.Haskeline.Term.html#FileOps"><span class="hs-identifier hs-type">FileOps</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-45"></span><span>            </span><span id="wrapInterrupt"><span class="annot"><span class="annottext">RunTerm
-&gt; forall a (m :: * -&gt; *). (MonadIO m, MonadMask m) =&gt; m a -&gt; m a
</span><a href="System.Console.Haskeline.Term.html#wrapInterrupt"><span class="hs-identifier hs-var hs-var">wrapInterrupt</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-keyword">forall</span><span> </span><span id="local-6989586621679095032"><span class="annot"><a href="#local-6989586621679095032"><span class="hs-identifier hs-type">a</span></a></span></span><span> </span><span id="local-6989586621679095033"><span class="annot"><a href="#local-6989586621679095033"><span class="hs-identifier hs-type">m</span></a></span></span><span> </span><span class="hs-operator">.</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Control.Monad.IO.Class.html#MonadIO"><span class="hs-identifier hs-type">MonadIO</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679095033"><span class="hs-identifier hs-type">m</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../exceptions/src/Control.Monad.Catch.html#MonadMask"><span class="hs-identifier hs-type">MonadMask</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679095033"><span class="hs-identifier hs-type">m</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679095033"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679095032"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679095033"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679095032"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-46"></span><span>            </span><span id="closeTerm"><span class="annot"><span class="annottext">RunTerm -&gt; IO ()
</span><a href="System.Console.Haskeline.Term.html#closeTerm"><span class="hs-identifier hs-var hs-var">closeTerm</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-47"></span><span>    </span><span class="hs-special">}</span><span>
</span><span id="line-48"></span><span>
</span><span id="line-49"></span><span class="hs-comment">-- | Operations needed for terminal-style interaction.</span><span>
</span><span id="line-50"></span><span class="hs-keyword">data</span><span> </span><span id="TermOps"><span class="annot"><a href="System.Console.Haskeline.Term.html#TermOps"><span class="hs-identifier hs-var">TermOps</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="TermOps"><span class="annot"><a href="System.Console.Haskeline.Term.html#TermOps"><span class="hs-identifier hs-var">TermOps</span></a></span></span><span>
</span><span id="line-51"></span><span>    </span><span class="hs-special">{</span><span> </span><span id="getLayout"><span class="annot"><span class="annottext">TermOps -&gt; IO Layout
</span><a href="System.Console.Haskeline.Term.html#getLayout"><span class="hs-identifier hs-var hs-var">getLayout</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="System.Console.Haskeline.Term.html#Layout"><span class="hs-identifier hs-type">Layout</span></a></span><span>
</span><span id="line-52"></span><span>    </span><span class="hs-special">,</span><span> </span><span id="withGetEvent"><span class="annot"><span class="annottext">TermOps
-&gt; forall (m :: * -&gt; *) a.
   CommandMonad m =&gt;
   (m Event -&gt; m a) -&gt; m a
</span><a href="System.Console.Haskeline.Term.html#withGetEvent"><span class="hs-identifier hs-var hs-var">withGetEvent</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-keyword">forall</span><span> </span><span id="local-6989586621679095029"><span class="annot"><a href="#local-6989586621679095029"><span class="hs-identifier hs-type">m</span></a></span></span><span> </span><span id="local-6989586621679095027"><span class="annot"><a href="#local-6989586621679095027"><span class="hs-identifier hs-type">a</span></a></span></span><span> </span><span class="hs-operator">.</span><span> </span><span class="annot"><a href="System.Console.Haskeline.Term.html#CommandMonad"><span class="hs-identifier hs-type">CommandMonad</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679095029"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679095029"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="annot"><a href="System.Console.Haskeline.Term.html#Event"><span class="hs-identifier hs-type">Event</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679095029"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679095027"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679095029"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679095027"><span class="hs-identifier hs-type">a</span></a></span><span>
</span><span id="line-53"></span><span>    </span><span class="hs-special">,</span><span> </span><span id="evalTerm"><span class="annot"><span class="annottext">TermOps -&gt; forall (m :: * -&gt; *). CommandMonad m =&gt; EvalTerm m
</span><a href="System.Console.Haskeline.Term.html#evalTerm"><span class="hs-identifier hs-var hs-var">evalTerm</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-keyword">forall</span><span> </span><span id="local-6989586621679095024"><span class="annot"><a href="#local-6989586621679095024"><span class="hs-identifier hs-type">m</span></a></span></span><span> </span><span class="hs-operator">.</span><span> </span><span class="annot"><a href="System.Console.Haskeline.Term.html#CommandMonad"><span class="hs-identifier hs-type">CommandMonad</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679095024"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="System.Console.Haskeline.Term.html#EvalTerm"><span class="hs-identifier hs-type">EvalTerm</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679095024"><span class="hs-identifier hs-type">m</span></a></span><span>
</span><span id="line-54"></span><span>    </span><span class="hs-special">,</span><span> </span><span id="saveUnusedKeys"><span class="annot"><span class="annottext">TermOps -&gt; [Key] -&gt; IO ()
</span><a href="System.Console.Haskeline.Term.html#saveUnusedKeys"><span class="hs-identifier hs-var hs-var">saveUnusedKeys</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="System.Console.Haskeline.Key.html#Key"><span class="hs-identifier hs-type">Key</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-55"></span><span>    </span><span class="hs-special">,</span><span> </span><span id="externalPrint"><span class="annot"><span class="annottext">TermOps -&gt; String -&gt; IO ()
</span><a href="System.Console.Haskeline.Term.html#externalPrint"><span class="hs-identifier hs-var hs-var">externalPrint</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-56"></span><span>    </span><span class="hs-special">}</span><span>
</span><span id="line-57"></span><span>
</span><span id="line-58"></span><span class="hs-comment">-- This hack is needed to grab latest writes from some other thread.</span><span>
</span><span id="line-59"></span><span class="hs-comment">-- Without it, if you are using another thread to process the logging</span><span>
</span><span id="line-60"></span><span class="hs-comment">-- and write on screen via exposed externalPrint, latest writes from</span><span>
</span><span id="line-61"></span><span class="hs-comment">-- this thread are not able to cross the thread boundary in time.</span><span>
</span><span id="line-62"></span><span class="annot"><a href="System.Console.Haskeline.Term.html#flushEventQueue"><span class="hs-identifier hs-type">flushEventQueue</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../stm/src/Control.Concurrent.STM.TChan.html#TChan"><span class="hs-identifier hs-type">TChan</span></a></span><span> </span><span class="annot"><a href="System.Console.Haskeline.Term.html#Event"><span class="hs-identifier hs-type">Event</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-63"></span><span id="flushEventQueue"><span class="annot"><span class="annottext">flushEventQueue :: (String -&gt; IO ()) -&gt; TChan Event -&gt; IO ()
</span><a href="System.Console.Haskeline.Term.html#flushEventQueue"><span class="hs-identifier hs-var hs-var">flushEventQueue</span></a></span></span><span> </span><span id="local-6989586621679094812"><span class="annot"><span class="annottext">String -&gt; IO ()
</span><a href="#local-6989586621679094812"><span class="hs-identifier hs-var">print'</span></a></span></span><span> </span><span id="local-6989586621679094811"><span class="annot"><span class="annottext">TChan Event
</span><a href="#local-6989586621679094811"><span class="hs-identifier hs-var">eventChan</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IO ()
</span><a href="../../base/src/GHC.Conc.Sync.html#yield"><span class="hs-identifier hs-var">yield</span></a></span><span> </span><span class="annot"><span class="annottext">IO () -&gt; IO () -&gt; IO ()
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; m b -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3E%3E"><span class="hs-operator hs-var">&gt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">IO ()
</span><a href="#local-6989586621679094809"><span class="hs-identifier hs-var">loopUntilFlushed</span></a></span><span>
</span><span id="line-64"></span><span>    </span><span class="hs-keyword">where</span><span> </span><span id="local-6989586621679094809"><span class="annot"><span class="annottext">loopUntilFlushed :: IO ()
</span><a href="#local-6989586621679094809"><span class="hs-identifier hs-var hs-var">loopUntilFlushed</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-65"></span><span>              </span><span id="local-6989586621679094804"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679094804"><span class="hs-identifier hs-var">flushed</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">STM Bool -&gt; IO Bool
forall a. STM a -&gt; IO a
</span><a href="../../base/src/GHC.Conc.Sync.html#atomically"><span class="hs-identifier hs-var">atomically</span></a></span><span> </span><span class="annot"><span class="annottext">(STM Bool -&gt; IO Bool) -&gt; STM Bool -&gt; IO Bool
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">TChan Event -&gt; STM Bool
forall a. TChan a -&gt; STM Bool
</span><a href="../../stm/src/Control.Concurrent.STM.TChan.html#isEmptyTChan"><span class="hs-identifier hs-var">isEmptyTChan</span></a></span><span> </span><span class="annot"><span class="annottext">TChan Event
</span><a href="#local-6989586621679094811"><span class="hs-identifier hs-var">eventChan</span></a></span><span>
</span><span id="line-66"></span><span>              </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679094804"><span class="hs-identifier hs-var">flushed</span></a></span><span> </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">() -&gt; IO ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span> </span><span class="hs-keyword">else</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-67"></span><span>                  </span><span id="local-6989586621679094801"><span class="annot"><span class="annottext">Event
</span><a href="#local-6989586621679094801"><span class="hs-identifier hs-var">event</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">STM Event -&gt; IO Event
forall a. STM a -&gt; IO a
</span><a href="../../base/src/GHC.Conc.Sync.html#atomically"><span class="hs-identifier hs-var">atomically</span></a></span><span> </span><span class="annot"><span class="annottext">(STM Event -&gt; IO Event) -&gt; STM Event -&gt; IO Event
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">TChan Event -&gt; STM Event
forall a. TChan a -&gt; STM a
</span><a href="../../stm/src/Control.Concurrent.STM.TChan.html#readTChan"><span class="hs-identifier hs-var">readTChan</span></a></span><span> </span><span class="annot"><span class="annottext">TChan Event
</span><a href="#local-6989586621679094811"><span class="hs-identifier hs-var">eventChan</span></a></span><span>
</span><span id="line-68"></span><span>                  </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Event
</span><a href="#local-6989586621679094801"><span class="hs-identifier hs-var">event</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-69"></span><span>                      </span><span class="annot"><a href="System.Console.Haskeline.Term.html#ExternalPrint"><span class="hs-identifier hs-type">ExternalPrint</span></a></span><span> </span><span id="local-6989586621679094798"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679094798"><span class="hs-identifier hs-var">str</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-70"></span><span>                          </span><span class="annot"><span class="annottext">String -&gt; IO ()
</span><a href="#local-6989586621679094812"><span class="hs-identifier hs-var">print'</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679094798"><span class="hs-identifier hs-var">str</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; String -&gt; String
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;\n&quot;</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">IO () -&gt; IO () -&gt; IO ()
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; m b -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3E%3E"><span class="hs-operator hs-var">&gt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">IO ()
</span><a href="#local-6989586621679094809"><span class="hs-identifier hs-var">loopUntilFlushed</span></a></span><span>
</span><span id="line-71"></span><span>                      </span><span class="hs-comment">-- We don't want to raise exceptions when doing cleanup.</span><span>
</span><span id="line-72"></span><span>                      </span><span class="annot"><span class="annottext">Event
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">IO ()
</span><a href="#local-6989586621679094809"><span class="hs-identifier hs-var">loopUntilFlushed</span></a></span><span>
</span><span id="line-73"></span><span>
</span><span id="line-74"></span><span class="hs-comment">-- | Operations needed for file-style interaction.</span><span>
</span><span id="line-75"></span><span class="hs-comment">--</span><span>
</span><span id="line-76"></span><span class="hs-comment">-- Backends can assume that getLocaleLine, getLocaleChar and maybeReadNewline</span><span>
</span><span id="line-77"></span><span class="hs-comment">-- are &quot;wrapped&quot; by wrapFileInput.</span><span>
</span><span id="line-78"></span><span class="hs-keyword">data</span><span> </span><span id="FileOps"><span class="annot"><a href="System.Console.Haskeline.Term.html#FileOps"><span class="hs-identifier hs-var">FileOps</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="FileOps"><span class="annot"><a href="System.Console.Haskeline.Term.html#FileOps"><span class="hs-identifier hs-var">FileOps</span></a></span></span><span> </span><span class="hs-special">{</span><span>
</span><span id="line-79"></span><span>            </span><span id="withoutInputEcho"><span class="annot"><span class="annottext">FileOps
-&gt; forall (m :: * -&gt; *) a. (MonadIO m, MonadMask m) =&gt; m a -&gt; m a
</span><a href="System.Console.Haskeline.Term.html#withoutInputEcho"><span class="hs-identifier hs-var hs-var">withoutInputEcho</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-keyword">forall</span><span> </span><span id="local-6989586621679095007"><span class="annot"><a href="#local-6989586621679095007"><span class="hs-identifier hs-type">m</span></a></span></span><span> </span><span id="local-6989586621679095006"><span class="annot"><a href="#local-6989586621679095006"><span class="hs-identifier hs-type">a</span></a></span></span><span> </span><span class="hs-operator">.</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Control.Monad.IO.Class.html#MonadIO"><span class="hs-identifier hs-type">MonadIO</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679095007"><span class="hs-identifier hs-type">m</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../exceptions/src/Control.Monad.Catch.html#MonadMask"><span class="hs-identifier hs-type">MonadMask</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679095007"><span class="hs-identifier hs-type">m</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679095007"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679095006"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679095007"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679095006"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-80"></span><span>            </span><span class="hs-comment">-- ^ Perform an action without echoing input.</span><span>
</span><span id="line-81"></span><span>            </span><span id="wrapFileInput"><span class="annot"><span class="annottext">FileOps -&gt; forall a. IO a -&gt; IO a
</span><a href="System.Console.Haskeline.Term.html#wrapFileInput"><span class="hs-identifier hs-var hs-var">wrapFileInput</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-keyword">forall</span><span> </span><span id="local-6989586621679095003"><span class="annot"><a href="#local-6989586621679095003"><span class="hs-identifier hs-type">a</span></a></span></span><span> </span><span class="hs-operator">.</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="#local-6989586621679095003"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="#local-6989586621679095003"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-82"></span><span>            </span><span id="getLocaleLine"><span class="annot"><span class="annottext">FileOps -&gt; MaybeT IO String
</span><a href="System.Console.Haskeline.Term.html#getLocaleLine"><span class="hs-identifier hs-var hs-var">getLocaleLine</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../transformers/src/Control.Monad.Trans.Maybe.html#MaybeT"><span class="hs-identifier hs-type">MaybeT</span></a></span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-83"></span><span>            </span><span id="getLocaleChar"><span class="annot"><span class="annottext">FileOps -&gt; MaybeT IO Char
</span><a href="System.Console.Haskeline.Term.html#getLocaleChar"><span class="hs-identifier hs-var hs-var">getLocaleChar</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../transformers/src/Control.Monad.Trans.Maybe.html#MaybeT"><span class="hs-identifier hs-type">MaybeT</span></a></span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Char</span></span><span class="hs-special">,</span><span>
</span><span id="line-84"></span><span>            </span><span id="maybeReadNewline"><span class="annot"><span class="annottext">FileOps -&gt; IO ()
</span><a href="System.Console.Haskeline.Term.html#maybeReadNewline"><span class="hs-identifier hs-var hs-var">maybeReadNewline</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-85"></span><span>        </span><span class="hs-special">}</span><span>
</span><span id="line-86"></span><span>
</span><span id="line-87"></span><span class="hs-comment">-- | Are we using terminal-style interaction?</span><span>
</span><span id="line-88"></span><span class="annot"><a href="System.Console.Haskeline.Term.html#isTerminalStyle"><span class="hs-identifier hs-type">isTerminalStyle</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="System.Console.Haskeline.Term.html#RunTerm"><span class="hs-identifier hs-type">RunTerm</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-89"></span><span id="isTerminalStyle"><span class="annot"><span class="annottext">isTerminalStyle :: RunTerm -&gt; Bool
</span><a href="System.Console.Haskeline.Term.html#isTerminalStyle"><span class="hs-identifier hs-var hs-var">isTerminalStyle</span></a></span></span><span> </span><span id="local-6989586621679094786"><span class="annot"><span class="annottext">RunTerm
</span><a href="#local-6989586621679094786"><span class="hs-identifier hs-var">r</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">RunTerm -&gt; Either TermOps FileOps
</span><a href="System.Console.Haskeline.Term.html#termOps"><span class="hs-identifier hs-var hs-var">termOps</span></a></span><span> </span><span class="annot"><span class="annottext">RunTerm
</span><a href="#local-6989586621679094786"><span class="hs-identifier hs-var">r</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-90"></span><span>                    </span><span class="annot"><a href="../../base/src/Data.Either.html#Left"><span class="hs-identifier hs-type">Left</span></a></span><span> </span><span class="annot"><a href="System.Console.Haskeline.Term.html#TermOps"><span class="hs-identifier hs-type">TermOps</span></a></span><span class="hs-special">{</span><span class="hs-special">}</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-91"></span><span>                    </span><span class="annot"><span class="annottext">Either TermOps FileOps
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-92"></span><span>
</span><span id="line-93"></span><span class="hs-comment">-- Specific, hidden terminal action type</span><span>
</span><span id="line-94"></span><span class="hs-comment">-- Generic terminal actions which are independent of the Term being used.</span><span>
</span><span id="line-95"></span><span class="hs-keyword">data</span><span> </span><span id="EvalTerm"><span class="annot"><a href="System.Console.Haskeline.Term.html#EvalTerm"><span class="hs-identifier hs-var">EvalTerm</span></a></span></span><span> </span><span id="local-6989586621679094990"><span class="annot"><a href="#local-6989586621679094990"><span class="hs-identifier hs-type">m</span></a></span></span><span>
</span><span id="line-96"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">forall</span><span> </span><span id="local-6989586621679094991"><span class="annot"><a href="#local-6989586621679094991"><span class="hs-identifier hs-type">n</span></a></span></span><span> </span><span class="hs-operator">.</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="System.Console.Haskeline.Term.html#Term"><span class="hs-identifier hs-type">Term</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679094991"><span class="hs-identifier hs-type">n</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="System.Console.Haskeline.Term.html#CommandMonad"><span class="hs-identifier hs-type">CommandMonad</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679094991"><span class="hs-identifier hs-type">n</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-97"></span><span>            </span><span class="hs-glyph">=&gt;</span><span> </span><span id="EvalTerm"><span class="annot"><a href="System.Console.Haskeline.Term.html#EvalTerm"><span class="hs-identifier hs-var">EvalTerm</span></a></span></span><span> </span><span class="hs-special">(</span><span class="hs-keyword">forall</span><span> </span><span id="local-6989586621679094993"><span class="annot"><a href="#local-6989586621679094993"><span class="hs-identifier hs-type">a</span></a></span></span><span> </span><span class="hs-operator">.</span><span> </span><span class="annot"><a href="#local-6989586621679094991"><span class="hs-identifier hs-type">n</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679094993"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679094990"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679094993"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="hs-keyword">forall</span><span> </span><span id="local-6989586621679094992"><span class="annot"><a href="#local-6989586621679094992"><span class="hs-identifier hs-type">a</span></a></span></span><span> </span><span class="hs-operator">.</span><span> </span><span class="annot"><a href="#local-6989586621679094990"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679094992"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679094991"><span class="hs-identifier hs-type">n</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679094992"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-98"></span><span>
</span><span id="line-99"></span><span id="local-6989586621679094998"><span id="local-6989586621679095000"><span class="annot"><a href="System.Console.Haskeline.Term.html#mapEvalTerm"><span class="hs-identifier hs-type">mapEvalTerm</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="hs-keyword">forall</span><span> </span><span id="local-6989586621679094999"><span class="annot"><a href="#local-6989586621679094999"><span class="hs-identifier hs-type">a</span></a></span></span><span> </span><span class="hs-operator">.</span><span> </span><span class="annot"><a href="#local-6989586621679095000"><span class="hs-identifier hs-type">n</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679094999"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679094998"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679094999"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="hs-keyword">forall</span><span> </span><span id="local-6989586621679094997"><span class="annot"><a href="#local-6989586621679094997"><span class="hs-identifier hs-type">a</span></a></span></span><span> </span><span class="hs-operator">.</span><span> </span><span class="annot"><a href="#local-6989586621679094998"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679094997"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679095000"><span class="hs-identifier hs-type">n</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679094997"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-100"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="System.Console.Haskeline.Term.html#EvalTerm"><span class="hs-identifier hs-type">EvalTerm</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679095000"><span class="hs-identifier hs-type">n</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="System.Console.Haskeline.Term.html#EvalTerm"><span class="hs-identifier hs-type">EvalTerm</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679094998"><span class="hs-identifier hs-type">m</span></a></span></span></span><span>
</span><span id="line-101"></span><span id="mapEvalTerm"><span class="annot"><span class="annottext">mapEvalTerm :: forall (n :: * -&gt; *) (m :: * -&gt; *).
(forall a. n a -&gt; m a)
-&gt; (forall a. m a -&gt; n a) -&gt; EvalTerm n -&gt; EvalTerm m
</span><a href="System.Console.Haskeline.Term.html#mapEvalTerm"><span class="hs-identifier hs-var hs-var">mapEvalTerm</span></a></span></span><span> </span><span id="local-6989586621679094783"><span class="annot"><span class="annottext">forall a. n a -&gt; m a
</span><a href="#local-6989586621679094783"><span class="hs-identifier hs-var">eval</span></a></span></span><span> </span><span id="local-6989586621679094782"><span class="annot"><span class="annottext">forall a. m a -&gt; n a
</span><a href="#local-6989586621679094782"><span class="hs-identifier hs-var">liftE</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="System.Console.Haskeline.Term.html#EvalTerm"><span class="hs-identifier hs-type">EvalTerm</span></a></span><span> </span><span id="local-6989586621679094777"><span class="annot"><span class="annottext">forall a. n a -&gt; n a
</span><a href="#local-6989586621679094777"><span class="hs-identifier hs-var">eval'</span></a></span></span><span> </span><span id="local-6989586621679094776"><span class="annot"><span class="annottext">forall a. n a -&gt; n a
</span><a href="#local-6989586621679094776"><span class="hs-identifier hs-var">liftE'</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-102"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(forall a. n a -&gt; m a) -&gt; (forall a. m a -&gt; n a) -&gt; EvalTerm m
forall (m :: * -&gt; *) (n :: * -&gt; *).
(Term n, CommandMonad n) =&gt;
(forall a. n a -&gt; m a) -&gt; (forall a. m a -&gt; n a) -&gt; EvalTerm m
</span><a href="System.Console.Haskeline.Term.html#EvalTerm"><span class="hs-identifier hs-var">EvalTerm</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">n a -&gt; m a
forall a. n a -&gt; m a
</span><a href="#local-6989586621679094783"><span class="hs-identifier hs-var">eval</span></a></span><span> </span><span class="annot"><span class="annottext">(n a -&gt; m a) -&gt; (n a -&gt; n a) -&gt; n a -&gt; m a
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">n a -&gt; n a
forall a. n a -&gt; n a
</span><a href="#local-6989586621679094777"><span class="hs-identifier hs-var">eval'</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">n a -&gt; n a
forall a. n a -&gt; n a
</span><a href="#local-6989586621679094776"><span class="hs-identifier hs-var">liftE'</span></a></span><span> </span><span class="annot"><span class="annottext">(n a -&gt; n a) -&gt; (m a -&gt; n a) -&gt; m a -&gt; n a
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">m a -&gt; n a
forall a. m a -&gt; n a
</span><a href="#local-6989586621679094782"><span class="hs-identifier hs-var">liftE</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-103"></span><span>
</span><span id="line-104"></span><span class="hs-keyword">data</span><span> </span><span id="Interrupt"><span class="annot"><a href="System.Console.Haskeline.Term.html#Interrupt"><span class="hs-identifier hs-var">Interrupt</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="Interrupt"><span class="annot"><a href="System.Console.Haskeline.Term.html#Interrupt"><span class="hs-identifier hs-var">Interrupt</span></a></span></span><span>
</span><span id="line-105"></span><span>                </span><span class="hs-keyword">deriving</span><span> </span><span class="hs-special">(</span><span id="local-6989586621679094768"><span id="local-6989586621679094770"><span id="local-6989586621679094772"><span class="annot"><span class="annottext">Int -&gt; Interrupt -&gt; String -&gt; String
[Interrupt] -&gt; String -&gt; String
Interrupt -&gt; String
(Int -&gt; Interrupt -&gt; String -&gt; String)
-&gt; (Interrupt -&gt; String)
-&gt; ([Interrupt] -&gt; String -&gt; String)
-&gt; Show Interrupt
forall a.
(Int -&gt; a -&gt; String -&gt; String)
-&gt; (a -&gt; String) -&gt; ([a] -&gt; String -&gt; String) -&gt; Show a
showList :: [Interrupt] -&gt; String -&gt; String
$cshowList :: [Interrupt] -&gt; String -&gt; String
show :: Interrupt -&gt; String
$cshow :: Interrupt -&gt; String
showsPrec :: Int -&gt; Interrupt -&gt; String -&gt; String
$cshowsPrec :: Int -&gt; Interrupt -&gt; String -&gt; String
</span><a href="../../base/src/GHC.Show.html#Show"><span class="hs-identifier hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var">Show</span></a></span></span></span></span><span class="hs-special">,</span><span class="annot"><a href="../../base/src/Data.Typeable.Internal.html#Typeable"><span class="hs-identifier hs-type">Typeable</span></a></span><span class="hs-special">,</span><span id="local-6989586621679094763"><span id="local-6989586621679094765"><span class="annot"><span class="annottext">Interrupt -&gt; Interrupt -&gt; Bool
(Interrupt -&gt; Interrupt -&gt; Bool)
-&gt; (Interrupt -&gt; Interrupt -&gt; Bool) -&gt; Eq Interrupt
forall a. (a -&gt; a -&gt; Bool) -&gt; (a -&gt; a -&gt; Bool) -&gt; Eq a
/= :: Interrupt -&gt; Interrupt -&gt; Bool
$c/= :: Interrupt -&gt; Interrupt -&gt; Bool
== :: Interrupt -&gt; Interrupt -&gt; Bool
$c== :: Interrupt -&gt; Interrupt -&gt; Bool
</span><span class="hs-identifier hs-var hs-var hs-var hs-var hs-var hs-var">Eq</span></span></span></span><span class="hs-special">)</span><span>
</span><span id="line-106"></span><span>
</span><span id="line-107"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621679094752"><span id="local-6989586621679094754"><span id="local-6989586621679094756"><span class="annot"><a href="../../base/src/GHC.Exception.Type.html#Exception"><span class="hs-identifier hs-type">Exception</span></a></span><span> </span><span class="annot"><a href="System.Console.Haskeline.Term.html#Interrupt"><span class="hs-identifier hs-type">Interrupt</span></a></span></span></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-108"></span><span>
</span><span id="line-109"></span><span>
</span><span id="line-110"></span><span>
</span><span id="line-111"></span><span class="hs-keyword">class</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="System.Console.Haskeline.Monads.html#MonadReader"><span class="hs-identifier hs-type">MonadReader</span></a></span><span> </span><span class="annot"><a href="System.Console.Haskeline.Prefs.html#Prefs"><span class="hs-identifier hs-type">Prefs</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679094980"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="System.Console.Haskeline.Monads.html#MonadReader"><span class="hs-identifier hs-type">MonadReader</span></a></span><span> </span><span class="annot"><a href="System.Console.Haskeline.Term.html#Layout"><span class="hs-identifier hs-type">Layout</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679094980"><span class="hs-identifier hs-type">m</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/Control.Monad.IO.Class.html#MonadIO"><span class="hs-identifier hs-type">MonadIO</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679094980"><span class="hs-identifier hs-type">m</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../exceptions/src/Control.Monad.Catch.html#MonadMask"><span class="hs-identifier hs-type">MonadMask</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679094980"><span class="hs-identifier hs-type">m</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-112"></span><span>        </span><span class="hs-glyph">=&gt;</span><span> </span><span id="CommandMonad"><span class="annot"><a href="System.Console.Haskeline.Term.html#CommandMonad"><span class="hs-identifier hs-var">CommandMonad</span></a></span></span><span> </span><span id="local-6989586621679094980"><span class="annot"><a href="#local-6989586621679094980"><span class="hs-identifier hs-type">m</span></a></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-113"></span><span>    </span><span id="runCompletion"><span class="annot"><a href="System.Console.Haskeline.Term.html#runCompletion"><span class="hs-identifier hs-type">runCompletion</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span class="hs-special">,</span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679094980"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span class="hs-special">,</span><span class="hs-special">[</span><span class="annot"><a href="System.Console.Haskeline.Completion.html#Completion"><span class="hs-identifier hs-type">Completion</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-114"></span><span>
</span><span id="line-115"></span><span id="local-6989586621679094972"><span id="local-6989586621679094973"><span class="hs-keyword">instance</span><span> </span><span class="hs-pragma">{-# OVERLAPPABLE</span><span> </span><span class="hs-pragma">#-}</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../transformers/src/Control.Monad.Trans.Class.html#MonadTrans"><span class="hs-identifier hs-type">MonadTrans</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679094973"><span class="hs-identifier hs-type">t</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="System.Console.Haskeline.Term.html#CommandMonad"><span class="hs-identifier hs-type">CommandMonad</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679094972"><span class="hs-identifier hs-type">m</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="System.Console.Haskeline.Monads.html#MonadReader"><span class="hs-identifier hs-type">MonadReader</span></a></span><span> </span><span class="annot"><a href="System.Console.Haskeline.Prefs.html#Prefs"><span class="hs-identifier hs-type">Prefs</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679094973"><span class="hs-identifier hs-type">t</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679094972"><span class="hs-identifier hs-type">m</span></a></span><span class="hs-special">)</span><span class="hs-special">,</span><span>
</span><span id="line-116"></span><span>        </span><span class="annot"><a href="../../base/src/Control.Monad.IO.Class.html#MonadIO"><span class="hs-identifier hs-type">MonadIO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679094973"><span class="hs-identifier hs-type">t</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679094972"><span class="hs-identifier hs-type">m</span></a></span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../exceptions/src/Control.Monad.Catch.html#MonadMask"><span class="hs-identifier hs-type">MonadMask</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679094973"><span class="hs-identifier hs-type">t</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679094972"><span class="hs-identifier hs-type">m</span></a></span><span class="hs-special">)</span><span class="hs-special">,</span><span>
</span><span id="line-117"></span><span>        </span><span class="annot"><a href="System.Console.Haskeline.Monads.html#MonadReader"><span class="hs-identifier hs-type">MonadReader</span></a></span><span> </span><span class="annot"><a href="System.Console.Haskeline.Term.html#Layout"><span class="hs-identifier hs-type">Layout</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679094973"><span class="hs-identifier hs-type">t</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679094972"><span class="hs-identifier hs-type">m</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-118"></span><span>            </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="System.Console.Haskeline.Term.html#CommandMonad"><span class="hs-identifier hs-type">CommandMonad</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679094973"><span class="hs-identifier hs-type">t</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679094972"><span class="hs-identifier hs-type">m</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-119"></span><span>    </span><span id="local-6989586621679094722"><span class="annot"><span class="annottext">runCompletion :: (String, String) -&gt; t m (String, [Completion])
</span><a href="#local-6989586621679094722"><span class="hs-identifier hs-var hs-var hs-var hs-var">runCompletion</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">m (String, [Completion]) -&gt; t m (String, [Completion])
forall (t :: (* -&gt; *) -&gt; * -&gt; *) (m :: * -&gt; *) a.
(MonadTrans t, Monad m) =&gt;
m a -&gt; t m a
</span><a href="../../transformers/src/Control.Monad.Trans.Class.html#lift"><span class="hs-identifier hs-var">lift</span></a></span><span> </span><span class="annot"><span class="annottext">(m (String, [Completion]) -&gt; t m (String, [Completion]))
-&gt; ((String, String) -&gt; m (String, [Completion]))
-&gt; (String, String)
-&gt; t m (String, [Completion])
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">(String, String) -&gt; m (String, [Completion])
forall (m :: * -&gt; *).
CommandMonad m =&gt;
(String, String) -&gt; m (String, [Completion])
</span><a href="System.Console.Haskeline.Term.html#runCompletion"><span class="hs-identifier hs-var">runCompletion</span></a></span></span></span><span>
</span><span id="line-120"></span><span>
</span><span id="line-121"></span><span class="hs-comment">-- Utility function for drawLineDiff instances.</span><span>
</span><span id="line-122"></span><span id="local-6989586621679094968"><span class="annot"><a href="System.Console.Haskeline.Term.html#matchInit"><span class="hs-identifier hs-type">matchInit</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Eq</span></span><span> </span><span class="annot"><a href="#local-6989586621679094968"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621679094968"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621679094968"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621679094968"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621679094968"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span></span><span>
</span><span id="line-123"></span><span id="matchInit"><span class="annot"><span class="annottext">matchInit :: forall a. Eq a =&gt; [a] -&gt; [a] -&gt; ([a], [a])
</span><a href="System.Console.Haskeline.Term.html#matchInit"><span class="hs-identifier hs-var hs-var">matchInit</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621679094716"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679094716"><span class="hs-identifier hs-var">x</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621679094715"><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679094715"><span class="hs-identifier hs-var">xs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span id="local-6989586621679094714"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679094714"><span class="hs-identifier hs-var">y</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621679094713"><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679094713"><span class="hs-identifier hs-var">ys</span></a></span></span><span class="hs-special">)</span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679094716"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; a -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679094714"><span class="hs-identifier hs-var">y</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[a] -&gt; [a] -&gt; ([a], [a])
forall a. Eq a =&gt; [a] -&gt; [a] -&gt; ([a], [a])
</span><a href="System.Console.Haskeline.Term.html#matchInit"><span class="hs-identifier hs-var">matchInit</span></a></span><span> </span><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679094715"><span class="hs-identifier hs-var">xs</span></a></span><span> </span><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679094713"><span class="hs-identifier hs-var">ys</span></a></span><span>
</span><span id="line-124"></span><span class="annot"><a href="System.Console.Haskeline.Term.html#matchInit"><span class="hs-identifier hs-var">matchInit</span></a></span><span> </span><span id="local-6989586621679094712"><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679094712"><span class="hs-identifier hs-var">xs</span></a></span></span><span> </span><span id="local-6989586621679094711"><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679094711"><span class="hs-identifier hs-var">ys</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679094712"><span class="hs-identifier hs-var">xs</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679094711"><span class="hs-identifier hs-var">ys</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-125"></span><span>
</span><span id="line-126"></span><span class="hs-keyword">data</span><span> </span><span id="Event"><span class="annot"><a href="System.Console.Haskeline.Term.html#Event"><span class="hs-identifier hs-var">Event</span></a></span></span><span>
</span><span id="line-127"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span id="WindowResize"><span class="annot"><a href="System.Console.Haskeline.Term.html#WindowResize"><span class="hs-identifier hs-var">WindowResize</span></a></span></span><span>
</span><span id="line-128"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span id="KeyInput"><span class="annot"><a href="System.Console.Haskeline.Term.html#KeyInput"><span class="hs-identifier hs-var">KeyInput</span></a></span></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="System.Console.Haskeline.Key.html#Key"><span class="hs-identifier hs-type">Key</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-129"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span id="ErrorEvent"><span class="annot"><a href="System.Console.Haskeline.Term.html#ErrorEvent"><span class="hs-identifier hs-var">ErrorEvent</span></a></span></span><span> </span><span class="annot"><a href="../../base/src/GHC.Exception.Type.html#SomeException"><span class="hs-identifier hs-type">SomeException</span></a></span><span>
</span><span id="line-130"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span id="ExternalPrint"><span class="annot"><a href="System.Console.Haskeline.Term.html#ExternalPrint"><span class="hs-identifier hs-var">ExternalPrint</span></a></span></span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span>
</span><span id="line-131"></span><span>  </span><span class="hs-keyword">deriving</span><span> </span><span id="local-6989586621679094691"><span id="local-6989586621679094693"><span id="local-6989586621679094706"><span class="annot"><span class="annottext">Int -&gt; Event -&gt; String -&gt; String
[Event] -&gt; String -&gt; String
Event -&gt; String
(Int -&gt; Event -&gt; String -&gt; String)
-&gt; (Event -&gt; String) -&gt; ([Event] -&gt; String -&gt; String) -&gt; Show Event
forall a.
(Int -&gt; a -&gt; String -&gt; String)
-&gt; (a -&gt; String) -&gt; ([a] -&gt; String -&gt; String) -&gt; Show a
showList :: [Event] -&gt; String -&gt; String
$cshowList :: [Event] -&gt; String -&gt; String
show :: Event -&gt; String
$cshow :: Event -&gt; String
showsPrec :: Int -&gt; Event -&gt; String -&gt; String
$cshowsPrec :: Int -&gt; Event -&gt; String -&gt; String
</span><a href="../../base/src/GHC.Show.html#Show"><span class="hs-identifier hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var">Show</span></a></span></span></span></span><span>
</span><span id="line-132"></span><span>
</span><span id="line-133"></span><span class="annot"><a href="System.Console.Haskeline.Term.html#keyEventLoop"><span class="hs-identifier hs-type">keyEventLoop</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="System.Console.Haskeline.Term.html#Event"><span class="hs-identifier hs-type">Event</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../stm/src/Control.Concurrent.STM.TChan.html#TChan"><span class="hs-identifier hs-type">TChan</span></a></span><span> </span><span class="annot"><a href="System.Console.Haskeline.Term.html#Event"><span class="hs-identifier hs-type">Event</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="System.Console.Haskeline.Term.html#Event"><span class="hs-identifier hs-type">Event</span></a></span><span>
</span><span id="line-134"></span><span id="keyEventLoop"><span class="annot"><span class="annottext">keyEventLoop :: IO [Event] -&gt; TChan Event -&gt; IO Event
</span><a href="System.Console.Haskeline.Term.html#keyEventLoop"><span class="hs-identifier hs-var hs-var">keyEventLoop</span></a></span></span><span> </span><span id="local-6989586621679094687"><span class="annot"><span class="annottext">IO [Event]
</span><a href="#local-6989586621679094687"><span class="hs-identifier hs-var">readEvents</span></a></span></span><span> </span><span id="local-6989586621679094686"><span class="annot"><span class="annottext">TChan Event
</span><a href="#local-6989586621679094686"><span class="hs-identifier hs-var">eventChan</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-135"></span><span>    </span><span class="hs-comment">-- first, see if any events are already queued up (from a key/ctrl-c</span><span>
</span><span id="line-136"></span><span>    </span><span class="hs-comment">-- event or from a previous call to getEvent where we read in multiple</span><span>
</span><span id="line-137"></span><span>    </span><span class="hs-comment">-- keys)</span><span>
</span><span id="line-138"></span><span>    </span><span id="local-6989586621679094685"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679094685"><span class="hs-identifier hs-var">isEmpty</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">STM Bool -&gt; IO Bool
forall a. STM a -&gt; IO a
</span><a href="../../base/src/GHC.Conc.Sync.html#atomically"><span class="hs-identifier hs-var">atomically</span></a></span><span> </span><span class="annot"><span class="annottext">(STM Bool -&gt; IO Bool) -&gt; STM Bool -&gt; IO Bool
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">TChan Event -&gt; STM Bool
forall a. TChan a -&gt; STM Bool
</span><a href="../../stm/src/Control.Concurrent.STM.TChan.html#isEmptyTChan"><span class="hs-identifier hs-var">isEmptyTChan</span></a></span><span> </span><span class="annot"><span class="annottext">TChan Event
</span><a href="#local-6989586621679094686"><span class="hs-identifier hs-var">eventChan</span></a></span><span>
</span><span id="line-139"></span><span>    </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679094685"><span class="hs-identifier hs-var">isEmpty</span></a></span><span>
</span><span id="line-140"></span><span>        </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">STM Event -&gt; IO Event
forall a. STM a -&gt; IO a
</span><a href="../../base/src/GHC.Conc.Sync.html#atomically"><span class="hs-identifier hs-var">atomically</span></a></span><span> </span><span class="annot"><span class="annottext">(STM Event -&gt; IO Event) -&gt; STM Event -&gt; IO Event
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">TChan Event -&gt; STM Event
forall a. TChan a -&gt; STM a
</span><a href="../../stm/src/Control.Concurrent.STM.TChan.html#readTChan"><span class="hs-identifier hs-var">readTChan</span></a></span><span> </span><span class="annot"><span class="annottext">TChan Event
</span><a href="#local-6989586621679094686"><span class="hs-identifier hs-var">eventChan</span></a></span><span>
</span><span id="line-141"></span><span>        </span><span class="hs-keyword">else</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-142"></span><span>            </span><span id="local-6989586621679094683"><span class="annot"><span class="annottext">ThreadId
</span><a href="#local-6989586621679094683"><span class="hs-identifier hs-var">tid</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IO () -&gt; IO ThreadId
</span><a href="../../base/src/GHC.Conc.Sync.html#forkIO"><span class="hs-identifier hs-var">forkIO</span></a></span><span> </span><span class="annot"><span class="annottext">(IO () -&gt; IO ThreadId) -&gt; IO () -&gt; IO ThreadId
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">IO () -&gt; IO ()
</span><a href="#local-6989586621679094681"><span class="hs-identifier hs-var">handleErrorEvent</span></a></span><span> </span><span class="annot"><span class="annottext">IO ()
</span><a href="#local-6989586621679094680"><span class="hs-identifier hs-var">readerLoop</span></a></span><span>
</span><span id="line-143"></span><span>            </span><span class="annot"><span class="annottext">STM Event -&gt; IO Event
forall a. STM a -&gt; IO a
</span><a href="../../base/src/GHC.Conc.Sync.html#atomically"><span class="hs-identifier hs-var">atomically</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TChan Event -&gt; STM Event
forall a. TChan a -&gt; STM a
</span><a href="../../stm/src/Control.Concurrent.STM.TChan.html#readTChan"><span class="hs-identifier hs-var">readTChan</span></a></span><span> </span><span class="annot"><span class="annottext">TChan Event
</span><a href="#local-6989586621679094686"><span class="hs-identifier hs-var">eventChan</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">IO Event -&gt; IO () -&gt; IO Event
forall (m :: * -&gt; *) a b. MonadMask m =&gt; m a -&gt; m b -&gt; m a
</span><a href="../../exceptions/src/Control.Monad.Catch.html#finally"><span class="hs-operator hs-var">`finally`</span></a></span><span> </span><span class="annot"><span class="annottext">ThreadId -&gt; IO ()
</span><a href="../../base/src/GHC.Conc.Sync.html#killThread"><span class="hs-identifier hs-var">killThread</span></a></span><span> </span><span class="annot"><span class="annottext">ThreadId
</span><a href="#local-6989586621679094683"><span class="hs-identifier hs-var">tid</span></a></span><span>
</span><span id="line-144"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-145"></span><span>    </span><span id="local-6989586621679094680"><span class="annot"><span class="annottext">readerLoop :: IO ()
</span><a href="#local-6989586621679094680"><span class="hs-identifier hs-var hs-var">readerLoop</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-146"></span><span>        </span><span id="local-6989586621679094672"><span class="annot"><span class="annottext">[Event]
</span><a href="#local-6989586621679094672"><span class="hs-identifier hs-var">es</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IO [Event]
</span><a href="#local-6989586621679094687"><span class="hs-identifier hs-var">readEvents</span></a></span><span>
</span><span id="line-147"></span><span>        </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">[Event] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">[Event]
</span><a href="#local-6989586621679094672"><span class="hs-identifier hs-var">es</span></a></span><span>
</span><span id="line-148"></span><span>            </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">IO ()
</span><a href="#local-6989586621679094680"><span class="hs-identifier hs-var">readerLoop</span></a></span><span>
</span><span id="line-149"></span><span>            </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">STM () -&gt; IO ()
forall a. STM a -&gt; IO a
</span><a href="../../base/src/GHC.Conc.Sync.html#atomically"><span class="hs-identifier hs-var">atomically</span></a></span><span> </span><span class="annot"><span class="annottext">(STM () -&gt; IO ()) -&gt; STM () -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">(Event -&gt; STM ()) -&gt; [Event] -&gt; STM ()
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Foldable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m ()
</span><a href="../../base/src/Data.Foldable.html#mapM_"><span class="hs-identifier hs-var">mapM_</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TChan Event -&gt; Event -&gt; STM ()
forall a. TChan a -&gt; a -&gt; STM ()
</span><a href="../../stm/src/Control.Concurrent.STM.TChan.html#writeTChan"><span class="hs-identifier hs-var">writeTChan</span></a></span><span> </span><span class="annot"><span class="annottext">TChan Event
</span><a href="#local-6989586621679094686"><span class="hs-identifier hs-var">eventChan</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Event]
</span><a href="#local-6989586621679094672"><span class="hs-identifier hs-var">es</span></a></span><span>
</span><span id="line-150"></span><span>    </span><span id="local-6989586621679094681"><span class="annot"><span class="annottext">handleErrorEvent :: IO () -&gt; IO ()
</span><a href="#local-6989586621679094681"><span class="hs-identifier hs-var hs-var">handleErrorEvent</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(SomeException -&gt; IO ()) -&gt; IO () -&gt; IO ()
forall (m :: * -&gt; *) e a.
(MonadCatch m, Exception e) =&gt;
(e -&gt; m a) -&gt; m a -&gt; m a
</span><a href="../../exceptions/src/Control.Monad.Catch.html#handle"><span class="hs-identifier hs-var">handle</span></a></span><span> </span><span class="annot"><span class="annottext">((SomeException -&gt; IO ()) -&gt; IO () -&gt; IO ())
-&gt; (SomeException -&gt; IO ()) -&gt; IO () -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679094661"><span class="annot"><span class="annottext">SomeException
</span><a href="#local-6989586621679094661"><span class="hs-identifier hs-var">e</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">SomeException -&gt; Maybe AsyncException
forall e. Exception e =&gt; SomeException -&gt; Maybe e
</span><a href="../../base/src/GHC.Exception.Type.html#fromException"><span class="hs-identifier hs-var">fromException</span></a></span><span> </span><span class="annot"><span class="annottext">SomeException
</span><a href="#local-6989586621679094661"><span class="hs-identifier hs-var">e</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-151"></span><span>                                </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="annot"><span class="annottext">AsyncException
</span><a href="../../base/src/GHC.IO.Exception.html#ThreadKilled"><span class="hs-identifier hs-var">ThreadKilled</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">() -&gt; IO ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-152"></span><span>                                </span><span class="annot"><span class="annottext">Maybe AsyncException
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">STM () -&gt; IO ()
forall a. STM a -&gt; IO a
</span><a href="../../base/src/GHC.Conc.Sync.html#atomically"><span class="hs-identifier hs-var">atomically</span></a></span><span> </span><span class="annot"><span class="annottext">(STM () -&gt; IO ()) -&gt; STM () -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">TChan Event -&gt; Event -&gt; STM ()
forall a. TChan a -&gt; a -&gt; STM ()
</span><a href="../../stm/src/Control.Concurrent.STM.TChan.html#writeTChan"><span class="hs-identifier hs-var">writeTChan</span></a></span><span> </span><span class="annot"><span class="annottext">TChan Event
</span><a href="#local-6989586621679094686"><span class="hs-identifier hs-var">eventChan</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SomeException -&gt; Event
</span><a href="System.Console.Haskeline.Term.html#ErrorEvent"><span class="hs-identifier hs-var">ErrorEvent</span></a></span><span> </span><span class="annot"><span class="annottext">SomeException
</span><a href="#local-6989586621679094661"><span class="hs-identifier hs-var">e</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-153"></span><span>
</span><span id="line-154"></span><span class="annot"><a href="System.Console.Haskeline.Term.html#saveKeys"><span class="hs-identifier hs-type">saveKeys</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../stm/src/Control.Concurrent.STM.TChan.html#TChan"><span class="hs-identifier hs-type">TChan</span></a></span><span> </span><span class="annot"><a href="System.Console.Haskeline.Term.html#Event"><span class="hs-identifier hs-type">Event</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="System.Console.Haskeline.Key.html#Key"><span class="hs-identifier hs-type">Key</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-155"></span><span id="saveKeys"><span class="annot"><span class="annottext">saveKeys :: TChan Event -&gt; [Key] -&gt; IO ()
</span><a href="System.Console.Haskeline.Term.html#saveKeys"><span class="hs-identifier hs-var hs-var">saveKeys</span></a></span></span><span> </span><span id="local-6989586621679094658"><span class="annot"><span class="annottext">TChan Event
</span><a href="#local-6989586621679094658"><span class="hs-identifier hs-var">ch</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">STM () -&gt; IO ()
forall a. STM a -&gt; IO a
</span><a href="../../base/src/GHC.Conc.Sync.html#atomically"><span class="hs-identifier hs-var">atomically</span></a></span><span> </span><span class="annot"><span class="annottext">(STM () -&gt; IO ()) -&gt; ([Key] -&gt; STM ()) -&gt; [Key] -&gt; IO ()
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">TChan Event -&gt; Event -&gt; STM ()
forall a. TChan a -&gt; a -&gt; STM ()
</span><a href="../../stm/src/Control.Concurrent.STM.TChan.html#writeTChan"><span class="hs-identifier hs-var">writeTChan</span></a></span><span> </span><span class="annot"><span class="annottext">TChan Event
</span><a href="#local-6989586621679094658"><span class="hs-identifier hs-var">ch</span></a></span><span> </span><span class="annot"><span class="annottext">(Event -&gt; STM ()) -&gt; ([Key] -&gt; Event) -&gt; [Key] -&gt; STM ()
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">[Key] -&gt; Event
</span><a href="System.Console.Haskeline.Term.html#KeyInput"><span class="hs-identifier hs-var">KeyInput</span></a></span><span>
</span><span id="line-156"></span><span>
</span><span id="line-157"></span><span class="hs-keyword">data</span><span> </span><span id="Layout"><span class="annot"><a href="System.Console.Haskeline.Term.html#Layout"><span class="hs-identifier hs-var">Layout</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="Layout"><span class="annot"><a href="System.Console.Haskeline.Term.html#Layout"><span class="hs-identifier hs-var">Layout</span></a></span></span><span> </span><span class="hs-special">{</span><span id="width"><span class="annot"><span class="annottext">Layout -&gt; Int
</span><a href="System.Console.Haskeline.Term.html#width"><span class="hs-identifier hs-var hs-var">width</span></a></span></span><span class="hs-special">,</span><span> </span><span id="height"><span class="annot"><span class="annottext">Layout -&gt; Int
</span><a href="System.Console.Haskeline.Term.html#height"><span class="hs-identifier hs-var hs-var">height</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span class="hs-special">}</span><span>
</span><span id="line-158"></span><span>                    </span><span class="hs-keyword">deriving</span><span> </span><span class="hs-special">(</span><span id="local-6989586621679094645"><span id="local-6989586621679094647"><span id="local-6989586621679094653"><span class="annot"><span class="annottext">Int -&gt; Layout -&gt; String -&gt; String
[Layout] -&gt; String -&gt; String
Layout -&gt; String
(Int -&gt; Layout -&gt; String -&gt; String)
-&gt; (Layout -&gt; String)
-&gt; ([Layout] -&gt; String -&gt; String)
-&gt; Show Layout
forall a.
(Int -&gt; a -&gt; String -&gt; String)
-&gt; (a -&gt; String) -&gt; ([a] -&gt; String -&gt; String) -&gt; Show a
showList :: [Layout] -&gt; String -&gt; String
$cshowList :: [Layout] -&gt; String -&gt; String
show :: Layout -&gt; String
$cshow :: Layout -&gt; String
showsPrec :: Int -&gt; Layout -&gt; String -&gt; String
$cshowsPrec :: Int -&gt; Layout -&gt; String -&gt; String
</span><a href="../../base/src/GHC.Show.html#Show"><span class="hs-identifier hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var">Show</span></a></span></span></span></span><span class="hs-special">,</span><span id="local-6989586621679094638"><span id="local-6989586621679094643"><span class="annot"><span class="annottext">Layout -&gt; Layout -&gt; Bool
(Layout -&gt; Layout -&gt; Bool)
-&gt; (Layout -&gt; Layout -&gt; Bool) -&gt; Eq Layout
forall a. (a -&gt; a -&gt; Bool) -&gt; (a -&gt; a -&gt; Bool) -&gt; Eq a
/= :: Layout -&gt; Layout -&gt; Bool
$c/= :: Layout -&gt; Layout -&gt; Bool
== :: Layout -&gt; Layout -&gt; Bool
$c== :: Layout -&gt; Layout -&gt; Bool
</span><span class="hs-identifier hs-var hs-var hs-var hs-var hs-var hs-var">Eq</span></span></span></span><span class="hs-special">)</span><span>
</span><span id="line-159"></span><span>
</span><span id="line-160"></span><span class="hs-comment">-----------------------------------</span><span>
</span><span id="line-161"></span><span class="hs-comment">-- Utility functions for the various backends.</span><span>
</span><span id="line-162"></span><span>
</span><span id="line-163"></span><span class="hs-comment">-- | Utility function since we're not using the new IO library yet.</span><span>
</span><span id="line-164"></span><span id="local-6989586621679094947"><span id="local-6989586621679094949"><span class="annot"><a href="System.Console.Haskeline.Term.html#hWithBinaryMode"><span class="hs-identifier hs-type">hWithBinaryMode</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Control.Monad.IO.Class.html#MonadIO"><span class="hs-identifier hs-type">MonadIO</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679094949"><span class="hs-identifier hs-type">m</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../exceptions/src/Control.Monad.Catch.html#MonadMask"><span class="hs-identifier hs-type">MonadMask</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679094949"><span class="hs-identifier hs-type">m</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679094949"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679094947"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679094949"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679094947"><span class="hs-identifier hs-type">a</span></a></span></span></span><span>
</span><span id="line-165"></span><span id="hWithBinaryMode"><span class="annot"><span class="annottext">hWithBinaryMode :: forall (m :: * -&gt; *) a.
(MonadIO m, MonadMask m) =&gt;
Handle -&gt; m a -&gt; m a
</span><a href="System.Console.Haskeline.Term.html#hWithBinaryMode"><span class="hs-identifier hs-var hs-var">hWithBinaryMode</span></a></span></span><span> </span><span id="local-6989586621679094627"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679094627"><span class="hs-identifier hs-var">h</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">m (Maybe TextEncoding)
-&gt; (Maybe TextEncoding -&gt; m ())
-&gt; (Maybe TextEncoding -&gt; m a)
-&gt; m a
forall (m :: * -&gt; *) a c b.
MonadMask m =&gt;
m a -&gt; (a -&gt; m c) -&gt; (a -&gt; m b) -&gt; m b
</span><a href="../../exceptions/src/Control.Monad.Catch.html#bracket"><span class="hs-identifier hs-var">bracket</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IO (Maybe TextEncoding) -&gt; m (Maybe TextEncoding)
forall (m :: * -&gt; *) a. MonadIO m =&gt; IO a -&gt; m a
</span><a href="../../base/src/Control.Monad.IO.Class.html#liftIO"><span class="hs-identifier hs-var">liftIO</span></a></span><span> </span><span class="annot"><span class="annottext">(IO (Maybe TextEncoding) -&gt; m (Maybe TextEncoding))
-&gt; IO (Maybe TextEncoding) -&gt; m (Maybe TextEncoding)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Handle -&gt; IO (Maybe TextEncoding)
</span><a href="../../base/src/GHC.IO.Handle.html#hGetEncoding"><span class="hs-identifier hs-var">hGetEncoding</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679094627"><span class="hs-identifier hs-var">h</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-166"></span><span>                        </span><span class="hs-special">(</span><span class="annot"><span class="annottext">m () -&gt; (TextEncoding -&gt; m ()) -&gt; Maybe TextEncoding -&gt; m ()
forall b a. b -&gt; (a -&gt; b) -&gt; Maybe a -&gt; b
</span><a href="../../base/src/Data.Maybe.html#maybe"><span class="hs-identifier hs-var">maybe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">() -&gt; m ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IO () -&gt; m ()
forall (m :: * -&gt; *) a. MonadIO m =&gt; IO a -&gt; m a
</span><a href="../../base/src/Control.Monad.IO.Class.html#liftIO"><span class="hs-identifier hs-var">liftIO</span></a></span><span> </span><span class="annot"><span class="annottext">(IO () -&gt; m ()) -&gt; (TextEncoding -&gt; IO ()) -&gt; TextEncoding -&gt; m ()
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">Handle -&gt; TextEncoding -&gt; IO ()
</span><a href="../../base/src/GHC.IO.Handle.html#hSetEncoding"><span class="hs-identifier hs-var">hSetEncoding</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679094627"><span class="hs-identifier hs-var">h</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-167"></span><span>                        </span><span class="annot"><span class="annottext">((Maybe TextEncoding -&gt; m a) -&gt; m a)
-&gt; (m a -&gt; Maybe TextEncoding -&gt; m a) -&gt; m a -&gt; m a
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">m a -&gt; Maybe TextEncoding -&gt; m a
forall a b. a -&gt; b -&gt; a
</span><a href="../../base/src/GHC.Base.html#const"><span class="hs-identifier hs-var">const</span></a></span><span> </span><span class="annot"><span class="annottext">(m a -&gt; Maybe TextEncoding -&gt; m a)
-&gt; (m a -&gt; m a) -&gt; m a -&gt; Maybe TextEncoding -&gt; m a
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IO () -&gt; m ()
forall (m :: * -&gt; *) a. MonadIO m =&gt; IO a -&gt; m a
</span><a href="../../base/src/Control.Monad.IO.Class.html#liftIO"><span class="hs-identifier hs-var">liftIO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Handle -&gt; Bool -&gt; IO ()
</span><a href="../../base/src/GHC.IO.Handle.html#hSetBinaryMode"><span class="hs-identifier hs-var">hSetBinaryMode</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679094627"><span class="hs-identifier hs-var">h</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">m () -&gt; m a -&gt; m a
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; m b -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3E%3E"><span class="hs-operator hs-var">&gt;&gt;</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-168"></span><span>
</span><span id="line-169"></span><span class="hs-comment">-- | Utility function for changing a property of a terminal for the duration of</span><span>
</span><span id="line-170"></span><span class="hs-comment">-- a computation.</span><span>
</span><span id="line-171"></span><span id="local-6989586621679094932"><span id="local-6989586621679094933"><span id="local-6989586621679094934"><span class="annot"><a href="System.Console.Haskeline.Term.html#bracketSet"><span class="hs-identifier hs-type">bracketSet</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../exceptions/src/Control.Monad.Catch.html#MonadMask"><span class="hs-identifier hs-type">MonadMask</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679094934"><span class="hs-identifier hs-type">m</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/Control.Monad.IO.Class.html#MonadIO"><span class="hs-identifier hs-type">MonadIO</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679094934"><span class="hs-identifier hs-type">m</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="#local-6989586621679094933"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679094933"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679094933"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679094934"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679094932"><span class="hs-identifier hs-type">b</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679094934"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679094932"><span class="hs-identifier hs-type">b</span></a></span></span></span></span><span>
</span><span id="line-172"></span><span id="bracketSet"><span class="annot"><span class="annottext">bracketSet :: forall (m :: * -&gt; *) a b.
(MonadMask m, MonadIO m) =&gt;
IO a -&gt; (a -&gt; IO ()) -&gt; a -&gt; m b -&gt; m b
</span><a href="System.Console.Haskeline.Term.html#bracketSet"><span class="hs-identifier hs-var hs-var">bracketSet</span></a></span></span><span> </span><span id="local-6989586621679094606"><span class="annot"><span class="annottext">IO a
</span><a href="#local-6989586621679094606"><span class="hs-identifier hs-var">getState</span></a></span></span><span> </span><span id="local-6989586621679094605"><span class="annot"><span class="annottext">a -&gt; IO ()
</span><a href="#local-6989586621679094605"><span class="hs-identifier hs-var">set</span></a></span></span><span> </span><span id="local-6989586621679094604"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679094604"><span class="hs-identifier hs-var">newState</span></a></span></span><span> </span><span id="local-6989586621679094603"><span class="annot"><span class="annottext">m b
</span><a href="#local-6989586621679094603"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">m a -&gt; (a -&gt; m ()) -&gt; (a -&gt; m b) -&gt; m b
forall (m :: * -&gt; *) a c b.
MonadMask m =&gt;
m a -&gt; (a -&gt; m c) -&gt; (a -&gt; m b) -&gt; m b
</span><a href="../../exceptions/src/Control.Monad.Catch.html#bracket"><span class="hs-identifier hs-var">bracket</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IO a -&gt; m a
forall (m :: * -&gt; *) a. MonadIO m =&gt; IO a -&gt; m a
</span><a href="../../base/src/Control.Monad.IO.Class.html#liftIO"><span class="hs-identifier hs-var">liftIO</span></a></span><span> </span><span class="annot"><span class="annottext">IO a
</span><a href="#local-6989586621679094606"><span class="hs-identifier hs-var">getState</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-173"></span><span>                            </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IO () -&gt; m ()
forall (m :: * -&gt; *) a. MonadIO m =&gt; IO a -&gt; m a
</span><a href="../../base/src/Control.Monad.IO.Class.html#liftIO"><span class="hs-identifier hs-var">liftIO</span></a></span><span> </span><span class="annot"><span class="annottext">(IO () -&gt; m ()) -&gt; (a -&gt; IO ()) -&gt; a -&gt; m ()
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; IO ()
</span><a href="#local-6989586621679094605"><span class="hs-identifier hs-var">set</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-174"></span><span>                            </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="annot"><span class="annottext">a
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">IO () -&gt; m ()
forall (m :: * -&gt; *) a. MonadIO m =&gt; IO a -&gt; m a
</span><a href="../../base/src/Control.Monad.IO.Class.html#liftIO"><span class="hs-identifier hs-var">liftIO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a -&gt; IO ()
</span><a href="#local-6989586621679094605"><span class="hs-identifier hs-var">set</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679094604"><span class="hs-identifier hs-var">newState</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">m () -&gt; m b -&gt; m b
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; m b -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3E%3E"><span class="hs-operator hs-var">&gt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">m b
</span><a href="#local-6989586621679094603"><span class="hs-identifier hs-var">f</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-175"></span><span>
</span><span id="line-176"></span><span class="hs-comment">-- | Returns one 8-bit word.  Needs to be wrapped by hWithBinaryMode.</span><span>
</span><span id="line-177"></span><span class="annot"><a href="System.Console.Haskeline.Term.html#hGetByte"><span class="hs-identifier hs-type">hGetByte</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../transformers/src/Control.Monad.Trans.Maybe.html#MaybeT"><span class="hs-identifier hs-type">MaybeT</span></a></span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span>
</span><span id="line-178"></span><span id="hGetByte"><span class="annot"><span class="annottext">hGetByte :: Handle -&gt; MaybeT IO Word8
</span><a href="System.Console.Haskeline.Term.html#hGetByte"><span class="hs-identifier hs-var hs-var">hGetByte</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Handle -&gt; IO Word8) -&gt; Handle -&gt; MaybeT IO Word8
forall a. (Handle -&gt; IO a) -&gt; Handle -&gt; MaybeT IO a
</span><a href="System.Console.Haskeline.Term.html#guardedEOF"><span class="hs-identifier hs-var">guardedEOF</span></a></span><span> </span><span class="annot"><span class="annottext">((Handle -&gt; IO Word8) -&gt; Handle -&gt; MaybeT IO Word8)
-&gt; (Handle -&gt; IO Word8) -&gt; Handle -&gt; MaybeT IO Word8
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">(Char -&gt; Word8) -&gt; IO Char -&gt; IO Word8
forall (m :: * -&gt; *) a1 r. Monad m =&gt; (a1 -&gt; r) -&gt; m a1 -&gt; m r
</span><a href="../../base/src/GHC.Base.html#liftM"><span class="hs-identifier hs-var">liftM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; Word8
forall a. Enum a =&gt; Int -&gt; a
</span><a href="../../base/src/GHC.Enum.html#toEnum"><span class="hs-identifier hs-var">toEnum</span></a></span><span> </span><span class="annot"><span class="annottext">(Int -&gt; Word8) -&gt; (Char -&gt; Int) -&gt; Char -&gt; Word8
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">Char -&gt; Int
forall a. Enum a =&gt; a -&gt; Int
</span><a href="../../base/src/GHC.Enum.html#fromEnum"><span class="hs-identifier hs-var">fromEnum</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(IO Char -&gt; IO Word8) -&gt; (Handle -&gt; IO Char) -&gt; Handle -&gt; IO Word8
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">Handle -&gt; IO Char
</span><a href="../../base/src/GHC.IO.Handle.Text.html#hGetChar"><span class="hs-identifier hs-var">hGetChar</span></a></span><span>
</span><span id="line-179"></span><span>
</span><span id="line-180"></span><span id="local-6989586621679094924"><span class="annot"><a href="System.Console.Haskeline.Term.html#guardedEOF"><span class="hs-identifier hs-type">guardedEOF</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="#local-6989586621679094924"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../transformers/src/Control.Monad.Trans.Maybe.html#MaybeT"><span class="hs-identifier hs-type">MaybeT</span></a></span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="#local-6989586621679094924"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-181"></span><span id="guardedEOF"><span class="annot"><span class="annottext">guardedEOF :: forall a. (Handle -&gt; IO a) -&gt; Handle -&gt; MaybeT IO a
</span><a href="System.Console.Haskeline.Term.html#guardedEOF"><span class="hs-identifier hs-var hs-var">guardedEOF</span></a></span></span><span> </span><span id="local-6989586621679094587"><span class="annot"><span class="annottext">Handle -&gt; IO a
</span><a href="#local-6989586621679094587"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span id="local-6989586621679094586"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679094586"><span class="hs-identifier hs-var">h</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-182"></span><span>    </span><span id="local-6989586621679094585"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679094585"><span class="hs-identifier hs-var">eof</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IO Bool -&gt; MaybeT IO Bool
forall (t :: (* -&gt; *) -&gt; * -&gt; *) (m :: * -&gt; *) a.
(MonadTrans t, Monad m) =&gt;
m a -&gt; t m a
</span><a href="../../transformers/src/Control.Monad.Trans.Class.html#lift"><span class="hs-identifier hs-var">lift</span></a></span><span> </span><span class="annot"><span class="annottext">(IO Bool -&gt; MaybeT IO Bool) -&gt; IO Bool -&gt; MaybeT IO Bool
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Handle -&gt; IO Bool
</span><a href="../../base/src/GHC.IO.Handle.html#hIsEOF"><span class="hs-identifier hs-var">hIsEOF</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679094586"><span class="hs-identifier hs-var">h</span></a></span><span>
</span><span id="line-183"></span><span>    </span><span class="annot"><span class="annottext">Bool -&gt; MaybeT IO ()
forall (f :: * -&gt; *). Alternative f =&gt; Bool -&gt; f ()
</span><a href="../../base/src/Control.Monad.html#guard"><span class="hs-identifier hs-var">guard</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679094585"><span class="hs-identifier hs-var">eof</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-184"></span><span>    </span><span class="annot"><span class="annottext">IO a -&gt; MaybeT IO a
forall (t :: (* -&gt; *) -&gt; * -&gt; *) (m :: * -&gt; *) a.
(MonadTrans t, Monad m) =&gt;
m a -&gt; t m a
</span><a href="../../transformers/src/Control.Monad.Trans.Class.html#lift"><span class="hs-identifier hs-var">lift</span></a></span><span> </span><span class="annot"><span class="annottext">(IO a -&gt; MaybeT IO a) -&gt; IO a -&gt; MaybeT IO a
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Handle -&gt; IO a
</span><a href="#local-6989586621679094587"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679094586"><span class="hs-identifier hs-var">h</span></a></span><span>
</span><span id="line-185"></span><span>
</span><span id="line-186"></span><span class="hs-comment">-- If another character is immediately available, and it is a newline, consume it.</span><span>
</span><span id="line-187"></span><span class="hs-comment">--</span><span>
</span><span id="line-188"></span><span class="hs-comment">-- Two portability fixes:</span><span>
</span><span id="line-189"></span><span class="hs-comment">--</span><span>
</span><span id="line-190"></span><span class="hs-comment">-- 1) By itself, this (by using hReady) might crash on invalid characters.</span><span>
</span><span id="line-191"></span><span class="hs-comment">-- The handle should be set to binary mode or a TextEncoder that</span><span>
</span><span id="line-192"></span><span class="hs-comment">-- transliterates or ignores invalid input.</span><span>
</span><span id="line-193"></span><span class="hs-comment">--</span><span>
</span><span id="line-194"></span><span class="hs-comment">-- 1) Note that in ghc-6.8.3 and earlier, hReady returns False at an EOF,</span><span>
</span><span id="line-195"></span><span class="hs-comment">-- whereas in ghc-6.10.1 and later it throws an exception.  (GHC trac #1063).</span><span>
</span><span id="line-196"></span><span class="hs-comment">-- This code handles both of those cases.</span><span>
</span><span id="line-197"></span><span class="annot"><a href="System.Console.Haskeline.Term.html#hMaybeReadNewline"><span class="hs-identifier hs-type">hMaybeReadNewline</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-198"></span><span id="hMaybeReadNewline"><span class="annot"><span class="annottext">hMaybeReadNewline :: Handle -&gt; IO ()
</span><a href="System.Console.Haskeline.Term.html#hMaybeReadNewline"><span class="hs-identifier hs-var hs-var">hMaybeReadNewline</span></a></span></span><span> </span><span id="local-6989586621679094582"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679094582"><span class="hs-identifier hs-var">h</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">() -&gt; IO () -&gt; IO ()
forall (m :: * -&gt; *) a. MonadMask m =&gt; a -&gt; m a -&gt; m a
</span><a href="System.Console.Haskeline.Term.html#returnOnEOF"><span class="hs-identifier hs-var">returnOnEOF</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(IO () -&gt; IO ()) -&gt; IO () -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-199"></span><span>    </span><span id="local-6989586621679094580"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679094580"><span class="hs-identifier hs-var">ready</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Handle -&gt; IO Bool
</span><a href="../../base/src/System.IO.html#hReady"><span class="hs-identifier hs-var">hReady</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679094582"><span class="hs-identifier hs-var">h</span></a></span><span>
</span><span id="line-200"></span><span>    </span><span class="annot"><span class="annottext">Bool -&gt; IO () -&gt; IO ()
forall (f :: * -&gt; *). Applicative f =&gt; Bool -&gt; f () -&gt; f ()
</span><a href="../../base/src/GHC.Base.html#when"><span class="hs-identifier hs-var">when</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679094580"><span class="hs-identifier hs-var">ready</span></a></span><span> </span><span class="annot"><span class="annottext">(IO () -&gt; IO ()) -&gt; IO () -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-201"></span><span>        </span><span id="local-6989586621679094578"><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621679094578"><span class="hs-identifier hs-var">c</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Handle -&gt; IO Char
</span><a href="../../base/src/GHC.IO.Handle.html#hLookAhead"><span class="hs-identifier hs-var">hLookAhead</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679094582"><span class="hs-identifier hs-var">h</span></a></span><span>
</span><span id="line-202"></span><span>        </span><span class="annot"><span class="annottext">Bool -&gt; IO () -&gt; IO ()
forall (f :: * -&gt; *). Applicative f =&gt; Bool -&gt; f () -&gt; f ()
</span><a href="../../base/src/GHC.Base.html#when"><span class="hs-identifier hs-var">when</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621679094578"><span class="hs-identifier hs-var">c</span></a></span><span> </span><span class="annot"><span class="annottext">Char -&gt; Char -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'\n'</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(IO () -&gt; IO ()) -&gt; IO () -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">IO Char
</span><a href="../../base/src/System.IO.html#getChar"><span class="hs-identifier hs-var">getChar</span></a></span><span> </span><span class="annot"><span class="annottext">IO Char -&gt; IO () -&gt; IO ()
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; m b -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3E%3E"><span class="hs-operator hs-var">&gt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">() -&gt; IO ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-203"></span><span>
</span><span id="line-204"></span><span id="local-6989586621679094913"><span id="local-6989586621679094914"><span class="annot"><a href="System.Console.Haskeline.Term.html#returnOnEOF"><span class="hs-identifier hs-type">returnOnEOF</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../exceptions/src/Control.Monad.Catch.html#MonadMask"><span class="hs-identifier hs-type">MonadMask</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679094914"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679094913"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679094914"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679094913"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679094914"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679094913"><span class="hs-identifier hs-type">a</span></a></span></span></span><span>
</span><span id="line-205"></span><span id="returnOnEOF"><span class="annot"><span class="annottext">returnOnEOF :: forall (m :: * -&gt; *) a. MonadMask m =&gt; a -&gt; m a -&gt; m a
</span><a href="System.Console.Haskeline.Term.html#returnOnEOF"><span class="hs-identifier hs-var hs-var">returnOnEOF</span></a></span></span><span> </span><span id="local-6989586621679094565"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679094565"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(IOError -&gt; m a) -&gt; m a -&gt; m a
forall (m :: * -&gt; *) e a.
(MonadCatch m, Exception e) =&gt;
(e -&gt; m a) -&gt; m a -&gt; m a
</span><a href="../../exceptions/src/Control.Monad.Catch.html#handle"><span class="hs-identifier hs-var">handle</span></a></span><span> </span><span class="annot"><span class="annottext">((IOError -&gt; m a) -&gt; m a -&gt; m a) -&gt; (IOError -&gt; m a) -&gt; m a -&gt; m a
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679094564"><span class="annot"><span class="annottext">IOError
</span><a href="#local-6989586621679094564"><span class="hs-identifier hs-var">e</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">IOError -&gt; Bool
</span><a href="../../base/src/System.IO.Error.html#isEOFError"><span class="hs-identifier hs-var">isEOFError</span></a></span><span> </span><span class="annot"><span class="annottext">IOError
</span><a href="#local-6989586621679094564"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-206"></span><span>                                </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">a -&gt; m a
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679094565"><span class="hs-identifier hs-var">x</span></a></span><span>
</span><span id="line-207"></span><span>                                </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">IOError -&gt; m a
forall (m :: * -&gt; *) e a. (MonadThrow m, Exception e) =&gt; e -&gt; m a
</span><a href="../../exceptions/src/Control.Monad.Catch.html#throwM"><span class="hs-identifier hs-var">throwM</span></a></span><span> </span><span class="annot"><span class="annottext">IOError
</span><a href="#local-6989586621679094564"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-208"></span><span>
</span><span id="line-209"></span><span class="hs-comment">-- | Utility function to correctly get a line of input as an undecoded ByteString.</span><span>
</span><span id="line-210"></span><span class="annot"><a href="System.Console.Haskeline.Term.html#hGetLocaleLine"><span class="hs-identifier hs-type">hGetLocaleLine</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../transformers/src/Control.Monad.Trans.Maybe.html#MaybeT"><span class="hs-identifier hs-type">MaybeT</span></a></span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="../../bytestring/src/Data.ByteString.Internal.html#ByteString"><span class="hs-identifier hs-type">ByteString</span></a></span><span>
</span><span id="line-211"></span><span id="hGetLocaleLine"><span class="annot"><span class="annottext">hGetLocaleLine :: Handle -&gt; MaybeT IO ByteString
</span><a href="System.Console.Haskeline.Term.html#hGetLocaleLine"><span class="hs-identifier hs-var hs-var">hGetLocaleLine</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Handle -&gt; IO ByteString) -&gt; Handle -&gt; MaybeT IO ByteString
forall a. (Handle -&gt; IO a) -&gt; Handle -&gt; MaybeT IO a
</span><a href="System.Console.Haskeline.Term.html#guardedEOF"><span class="hs-identifier hs-var">guardedEOF</span></a></span><span> </span><span class="annot"><span class="annottext">((Handle -&gt; IO ByteString) -&gt; Handle -&gt; MaybeT IO ByteString)
-&gt; (Handle -&gt; IO ByteString) -&gt; Handle -&gt; MaybeT IO ByteString
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679094562"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679094562"><span class="hs-identifier hs-var">h</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-212"></span><span>    </span><span class="hs-comment">-- It's more efficient to use B.getLine, but that function throws an</span><span>
</span><span id="line-213"></span><span>    </span><span class="hs-comment">-- error if the Handle (e.g., stdin) is set to NoBuffering.</span><span>
</span><span id="line-214"></span><span>    </span><span id="local-6989586621679094561"><span class="annot"><span class="annottext">BufferMode
</span><a href="#local-6989586621679094561"><span class="hs-identifier hs-var">buff</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IO BufferMode -&gt; IO BufferMode
forall (m :: * -&gt; *) a. MonadIO m =&gt; IO a -&gt; m a
</span><a href="../../base/src/Control.Monad.IO.Class.html#liftIO"><span class="hs-identifier hs-var">liftIO</span></a></span><span> </span><span class="annot"><span class="annottext">(IO BufferMode -&gt; IO BufferMode) -&gt; IO BufferMode -&gt; IO BufferMode
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Handle -&gt; IO BufferMode
</span><a href="../../base/src/GHC.IO.Handle.html#hGetBuffering"><span class="hs-identifier hs-var">hGetBuffering</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679094562"><span class="hs-identifier hs-var">h</span></a></span><span>
</span><span id="line-215"></span><span>    </span><span class="annot"><span class="annottext">IO ByteString -&gt; IO ByteString
forall (m :: * -&gt; *) a. MonadIO m =&gt; IO a -&gt; m a
</span><a href="../../base/src/Control.Monad.IO.Class.html#liftIO"><span class="hs-identifier hs-var">liftIO</span></a></span><span> </span><span class="annot"><span class="annottext">(IO ByteString -&gt; IO ByteString) -&gt; IO ByteString -&gt; IO ByteString
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">BufferMode
</span><a href="#local-6989586621679094561"><span class="hs-identifier hs-var">buff</span></a></span><span> </span><span class="annot"><span class="annottext">BufferMode -&gt; BufferMode -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">BufferMode
</span><a href="../../base/src/GHC.IO.Handle.Types.html#NoBuffering"><span class="hs-identifier hs-var">NoBuffering</span></a></span><span>
</span><span id="line-216"></span><span>        </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">(String -&gt; ByteString) -&gt; IO String -&gt; IO ByteString
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/GHC.Base.html#fmap"><span class="hs-identifier hs-var">fmap</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; ByteString
</span><a href="../../bytestring/src/Data.ByteString.Char8.html#pack"><span class="hs-identifier hs-var">BC.pack</span></a></span><span> </span><span class="annot"><span class="annottext">(IO String -&gt; IO ByteString) -&gt; IO String -&gt; IO ByteString
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Handle -&gt; IO String
</span><a href="../../base/src/GHC.IO.Handle.Text.html#hGetLine"><span class="hs-identifier hs-var">System.IO.hGetLine</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679094562"><span class="hs-identifier hs-var">h</span></a></span><span>
</span><span id="line-217"></span><span>        </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">Handle -&gt; IO ByteString
</span><a href="../../bytestring/src/Data.ByteString.html#hGetLine"><span class="hs-identifier hs-var">BC.hGetLine</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679094562"><span class="hs-identifier hs-var">h</span></a></span><span>
</span><span id="line-218"></span></pre></body></html>